package com.nuanshui.heatedloan.task.failover.strategy;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.fastjson.JSON;
import com.nuanshui.heatedloan.task.dal.mapper.TaskJobFailMapper;
import com.nuanshui.heatedloan.task.facade.model.TaskJobFail;
import com.nuanshui.heatedloan.task.failover.TaskFailMessage;

/**
 * 默认定时任务失败执行的策略
 * @param 
 * @author guohao
 * @date 2017年1月4日 下午4:08:10
 * @since $
 */
public class TaskFailDefaultStrategy extends AbstractTaskFailStrategy {

	
	
	@Autowired
	private TaskJobFailMapper taskJobFailMapper;
	
	
	@Override
	public void doHandler(TaskFailMessage taskFailMessage) {	   	  
		TaskJobFail taskJobFail = new TaskJobFail();
		taskJobFail.setFailTime(taskFailMessage.getFailTime());
		taskJobFail.setJobCode(taskFailMessage.getCode());
		taskJobFail.setJobName(taskFailMessage.getJobName());
		taskJobFail.setJobGroup(taskFailMessage.getJobGroup());
		taskJobFail.setJobParams(JSON.toJSONString(taskFailMessage.getJobParams()));
		taskJobFail.setNum(taskFailMessage.getNum());
		taskJobFailMapper.save(taskJobFail);	
	}	
}
